using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace Website
{
    public partial class Players : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            // Display all accounts
            if (lAccount.Items.Count == 0)
            {
                foreach (Domain.Account acc in Database.ObjectManager<Domain.Account>.Get())
                {
                    lAccount.Items.Add(acc.Username);
                }
            }
        }

        protected void lAccount_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Retrieve account
            Domain.Account acc = Database.ObjectManager<Domain.Account>.Get(lAccount.SelectedValue);

            // Display all players
            lPlayer.Items.Clear();
            foreach (Domain.Player player in acc.Players)
            {
                lPlayer.Items.Add(player.Name);
            }
        }

        protected void lPlayer_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Retrieve player
            Domain.Player player = Database.ObjectManager<Domain.Player>.Get(lPlayer.SelectedValue);

            // Display values
            txfName.Text = player.Name;
            txfHealth.Text = "" + player.Health;
            txfPosition.Text = "(" + player.X + ", " + player.Y + ", " + player.Z + ")";
        }

        protected void Button1_Click(object sender, EventArgs e)
        {

        }
    }
}
